﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once

#include "IUnCommandControlDefinition.h"
#include "IGalleryItemDefinition.h"

namespace gcmp
{
    class IGalleryEvent;

    /// \brief Gallery控件数据定义接口
    class GCMP_GUI_BASE_INTERFACE_EXPORT IGalleryDefinition : public IControlDefinition
    {
    public:
        /// \brief 创建IGalleryDefinition对象
        ///
        /// \param id       IGalleryDefinition的id,需保证唯一性
        /// \param caption    gallery控件标题
        /// \param columnCount  gallery里面子控件的列数
        /// \param itemWidth  galleryItem的宽度
        /// \param itemHeight  galleryItem的高度
        /// \return  创建出ILineEditDefinition对象。失败时返回空
        static OwnerPtr<IGalleryDefinition> Create(const std::wstring& id, const std::wstring& caption, int columnCount = 4, int itemWidth = 16, int itemHeight = 16);

        /// \brief 创建pGalleryDefinition的引用
        ///
        /// 不能通过引用创建引用；pGalleryDefinition需加到IControlDefinitionLibrary时才能创建引用对象
        /// \param pGalleryDefinition 被引用的IGalleryDefinition对象
        /// \return pGalleryDefinition的引用对象
        static OwnerPtr<IGalleryDefinition> CreateReference(const IGalleryDefinition* pGalleryDefinition);

        /// \brief 添加item至最后
        ///
        /// \param id       IGalleryItemDefinition的Id,需保证唯一性
        /// \param caption    控件标题
        /// \param tooltip    控件的提示信息
        /// \param iconPath   图标路径
        /// \param userData  用户数据
        /// \return   true表示成功，如果gallery已添加过Id为id的pGalleryItem,则返回false 
        virtual bool AddItem(const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip, const std::wstring& iconPath, const Any& userData) = 0;

        /// \brief 插入galleryItem
        ///
        /// \param beforeId  被插入对象的Id
        /// \param id       将插入的IGalleryItemDefinition的Id,需保证唯一性
        /// \param caption    控件标题
        /// \param tooltip    控件的提示信息
        /// \param iconPath   图标路径
        /// \param userData  用户数据        
        /// \return bool    true表示成功， 如果gallery不包含Id为beforeId的galleryItem或包含Id为id的pGalleryItem,则返回false
        virtual bool InsertItem(const std::wstring& beforeId, const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip, const std::wstring& iconPath, const Any& userData) = 0;
 
        /// \brief 删除galleryItem
        ///
        /// \param id    将删除对象的Id
        /// \return  true表示成功，如果gallery不包含Id为id的galleryItem,则返回false
        virtual bool DeleteItem(const std::wstring& id) = 0;

        /// \brief 删除所有galleryItem
        ///
        /// \return  true表示成功，false表示失败
        virtual bool DeleteAllItems() = 0;

        /// \brief 得到IGalleryItemDefinition对象
        ///
        /// \param index   索引
        /// \return IGalleryItemDefinition对象，失败时返回空指针
        virtual IGalleryItemDefinition* GetItem(int index) const = 0;

        /// \brief 得到IGalleryItemDefinition对象
        ///
        /// \param id   GalleryItemDefinition的id
        /// \return  IGalleryItemDefinition对象，失败时返回空指针
        virtual IGalleryItemDefinition* GetItem(const std::wstring& id) const = 0;

        /// \brief 得到IGalleryItemDefinition对象索引
        ///
        /// \param id   GalleryItemDefinition的id
        /// \return  IGalleryItemDefinition对象索引，失败时返回-1
        virtual int GetItemIndex(const std::wstring& id) const = 0;
       
        /// \brief 得到所有的item
        ///
        /// \return  galleryItem集合
        virtual std::vector<IGalleryItemDefinition*> GetAllItems() const = 0;
        
        /// \brief 得到当前被选中的IGalleryItemDefinition对象
        ///
        /// \return  IGalleryItemDefinition对象
        virtual const IGalleryItemDefinition* GetCurrentItem() const = 0;

        /// \brief 得到当前被选中的IGalleryItemDefinition对象索引
        ///
        /// \return  IGalleryItemDefinition对象索引
        virtual int GetCurrentIndex() const = 0;
       
        /// \brief 设置被选中的galleryItem
        ///
        /// \param id       galleryItem名字
        /// \return  true表示成功，如果gallery不包含Id为id的galleryItem,则返回alse
        virtual bool SetCurrentGalleryItem(const std::wstring& id) = 0;

        /// \brief 设置列数
        ///
        /// \param columnCount 列数
        /// \return  true表示成功， false表示失败,columnCount<1会返回失败，设置不起作用
        virtual bool SetColumnCount(int columnCount) = 0;
      
        /// \brief 得到IGalleryEvent对象
        ///
        /// \return IGalleryEvent对象
        virtual IGalleryEvent* GetEvent() const = 0;
    };
}

